namespace FreeSwitch.EventSocket.Events.System
{
	/// <summary>
	/// Heartbeat with current FreeSwitch status
	/// </summary>
	[EventName("HEARTBEAT")]
	public class Heartbeat : Event
	{
		private int _sessionCount;

		public string Info { get; set; }

		public string UpTime { get; set; }

		public int SessionCount
		{
			get { return _sessionCount; }
			set { _sessionCount = value; }
		}

		public override bool ParseCommand(string name, string value)
		{
			switch (name)
			{
				case "event-info":
					Info = value;
					break;
				case "up-time":
					UpTime = value;
					break;
				case "session-count":
					int.TryParse(value, out _sessionCount);
					break;

				default:
					return base.ParseCommand(name, value);
			}

			return true;

		}

		public override string ToString()
		{
			return string.Format("Hearbeat(upTime: {0}, sessionCount: {1})", UpTime, SessionCount);
		}
	}
}